﻿using System.Windows.Controls;
using jSLApp.Client.Forms;
using jSLCore.Client.Presentation;
using jSLCore.Client.Presentation.ApplicationContainer;
using jSLCore.Client.Presentation.BaseControl;

namespace jSLApp.Client.ApplicationBase
{
    public partial class MainContentContainer : ContentContainerBase
    {
        private BaseControl _defaultPage;

        public MainContentContainer()
        {
            InitializeComponent();
        }

        public static MainContentContainer Current
        {
            get { return (MainContentContainer) ApplicationContainer.CurrentContentContainer; }
        }

        public override void ShowPage(BaseControl control)
        {
            base.ShowPage(control);
            BindPage(control);
        }

        private void BindPage(BaseControl control)
        {
            imgHeader.Header = control.Title;
            imgHeader.Image = control.Icon;
        }

        protected override BaseControl GetDefaultPage()
        {
            return _defaultPage ?? (_defaultPage = new StartPage());
        }

        protected override ContentPresenter GetMainContentPresenter()
        {
            return mainContent;
        }
    }
}